package io.itit.ecp.admin.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.DeviceWarningThresholdEntity;
import io.itit.ecp.admin.server.mapper.DeviceWarningThresholdMapper;
import io.itit.ecp.admin.server.service.IDeviceWarningThresholdService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;


@Service
public class DeviceWarningThresholdServiceImpl extends JoinServiceImpl<DeviceWarningThresholdMapper, DeviceWarningThresholdEntity>
        implements IDeviceWarningThresholdService {

    @Override
    public List<DeviceWarningThresholdEntity> findByDeviceWarningId(String deviceWarnId) {
        return list(new LambdaQueryWrapper<DeviceWarningThresholdEntity>()
                .eq(DeviceWarningThresholdEntity::getDeviceWarningId, deviceWarnId));
    }

    @Override
    public void removeByDeviceWarningId(Serializable deviceWarnId) {
        remove(new LambdaQueryWrapper<DeviceWarningThresholdEntity>()
                .eq(DeviceWarningThresholdEntity::getDeviceWarningId, deviceWarnId));
    }

    @Override
    public void removeByDeviceWarningIds(Collection<?> deviceWarnIds) {
        if (!CollectionUtils.isEmpty(deviceWarnIds)) {
            remove(new LambdaQueryWrapper<DeviceWarningThresholdEntity>()
                    .in(DeviceWarningThresholdEntity::getDeviceWarningId, deviceWarnIds));
        }
    }
}
